/**
 * 
 */
package com.vector.ding.safe.impl;

import java.io.Serializable;
import java.util.Map;

import com.vector.ding.commons.util.BeanUtil;
import com.vector.ding.dao.mybatis.model.User;
import com.vector.ding.safe.IUser;

/**
 * @author vector
 *
 */
public class DefaultUser implements IUser, Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -989801365316914291L;
	
	
	private User user;
	private Map<String, Object> attributes;
	
	public DefaultUser(User user) {
		this.user = user;
		this.user.setPassword("*****");
		this.attributes = BeanUtil.getPropertyMap(user);
	}

	/* (non-Javadoc)
	 * @see com.vector.ding.safe.User#getId()
	 */
	public String getId() {
		return user.getId();
	}

	/* (non-Javadoc)
	 * @see com.vector.ding.safe.User#getLoginName()
	 */
	public String getLoginName() {
		return user.getName();
	}

	/* (non-Javadoc)
	 * @see com.vector.ding.safe.User#getRealName()
	 */
	public String getRealName() {
		return user.getName();
	}

	/* (non-Javadoc)
	 * @see com.vector.ding.safe.User#getAttribute()
	 */
	public Object getAttribute(String key) {
		return attributes.get(key);
	}

	/* (non-Javadoc)
	 * @see com.vector.ding.safe.User#getAttributes()
	 */
	public Map<String, Object> getAttributes() {
		return attributes;
	}

}
